<html className="no-js" lang="en">
  <head>
    <meta charset="utf-8" />
    <title>0Auth Callback</title>
    <meta name="description" content="" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#fafafa" />
    <noscript><meta http-equiv="refresh" content="0;url=/" /></noscript>
  </head>
  <body>
    {{#if error}}<pre><code>{{error.stack}}</code></pre>{{/if}}
    <script id="user" type="application/json">{{{json user}}}</script>
    {{! prettier-ignore }}
    <script>
      var error = {{#if error}}{{{json error.message}}}{{else}}null{{/if}};
      var user = JSON.parse(document.getElementById("user").text);
      var method = {{#if method}}"{{method}}"{{else}}null{{/if}};

      if (window.opener && !window.opener.closed) {
        var user = JSON.parse(document.getElementById("user").text);
        window.opener.sessionStorage.setItem("user", JSON.stringify(user));
        window.opener.postMessage({ user, method, error }, window.location.origin);
        window.close();
      } else if (!error) {
        var returnUrl = window.sessionStorage.getItem("return") || "/";
        window.location.href = returnUrl;
      }
    </script>
  </body>
</html>